﻿using AutoMapper;
using B.S.Packaged.Domain;
using B.S.Packaged.ErrorCode;
using B.S.Packaged.WebAPI.Read.Application.Command.PackagingQualityCommand;
using MediatR;
using SqlSugar;

namespace B.S.Packaged.WebAPI.Read.Application.CommandHander.PackagingQualityHandler
{
    public class FTPackagingQualityHandler : IRequestHandler<FTPackagingQualityCommand, APIResult<List<PackagingQuality>>>
    {
        private readonly ISqlSugarClient db;
        private readonly IMapper mapper;
        public FTPackagingQualityHandler(ISqlSugarClient db, IMapper mapper)
        {
            this.db = db;
            this.mapper = mapper;
        }
        public async Task<APIResult<List<PackagingQuality>>> Handle(FTPackagingQualityCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<PackagingQuality>> result = new APIResult<List<PackagingQuality>>();
            var list = await db.Queryable<PackagingQuality>().Where(x => x.IsDel == false && x.id == request.id).ToListAsync();
            result.data = list;
            result.code = APIResultCode.success;
            result.msg = "包装成品质检显示成功";
            return await Task.FromResult(result);
        }
    }
}
